package GUI;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import GUI.manager.VentanaFactory;
import GUI.manager.VentanaManager;

import core.model.Provincia;
import core.model.Usuario;

public class panelOpciones extends javax.swing.JPanel implements ActionListener, MouseListener {

	private static final int OK_CANCEL_OPTION = 0;
	private static final int PLAIN_MESSAGE = 0;
	public static int cod_provincia;
	

	public panelOpciones() {
		initComponents();
	}

	private void initComponents() {

		bTitulo = new javax.swing.JButton();
        etiquetaNick = new javax.swing.JLabel();
        botonSalir = new javax.swing.JButton();
        panelCentro = new javax.swing.JPanel();
        bAceptar = new javax.swing.JButton();
        etiquetaNick1 = new javax.swing.JLabel();
        etiquetaApellido2 = new javax.swing.JLabel();
        etiquetaEmail = new javax.swing.JLabel();
        etiquetaPassword = new javax.swing.JLabel();
        etiquetaPassword2 = new javax.swing.JLabel();
        etiquetaNombre = new javax.swing.JLabel();
        etiquetaProvincia = new javax.swing.JLabel();
        etiquetaApellido1 = new javax.swing.JLabel();
        tfNombre = new javax.swing.JTextField();
        tfApellido1 = new javax.swing.JTextField();
        tfApellido2 = new javax.swing.JTextField();
        tfNick = new javax.swing.JTextField();
        tfEmail = new javax.swing.JTextField();
        cbProvincia = new javax.swing.JComboBox();
        bMapa = new javax.swing.JButton();
        pfPassword1 = new javax.swing.JPasswordField();
        pfPassword2 = new javax.swing.JPasswordField();
        etiquetaEntrada = new javax.swing.JLabel();
        bBusqueda = new javax.swing.JButton();
        bAyuda = new javax.swing.JButton();
        bHistorial = new javax.swing.JButton();
        bSugerencias = new javax.swing.JButton();
        bCrearLista = new javax.swing.JButton();
        bOpciones = new javax.swing.JButton();

        
    	VentanaManager ventanaManager = VentanaFactory.getInstance();
    	List<Provincia> provincias = ventanaManager.getAllProvincias();
    	Usuario user=ventanaManager.findUsuarioBy(panelPrincipal.nick);
    	
		setBackground(new java.awt.Color(255, 255, 255));
		
		pfPassword1.addMouseListener(this);
		pfPassword2.addMouseListener(this);
		

		bTitulo.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/encabezadoMain.png")); // NOI18N
		bTitulo.setBorder(null);
		bTitulo.setBorderPainted(false);
		bTitulo.addActionListener(this);
		bTitulo.setBackground(new java.awt.Color(255, 255, 255));

		bSugerencias.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bSugerencias.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonSugerencias.png")); // NOI18N
		bSugerencias.setBorderPainted(false);
		bSugerencias.addActionListener(this);
		bSugerencias.setBackground(new java.awt.Color(255, 255, 255));

		bCrearLista.setBackground(new java.awt.Color(255, 255, 255));
		bCrearLista.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bCrearLista.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonCrearLista.png")); // NOI18N
		bCrearLista.setBorderPainted(false);
		bCrearLista.addActionListener(this);

		bHistorial.setBackground(new java.awt.Color(255, 255, 255));
		bHistorial.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bHistorial.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonHistorial.png")); // NOI18N
		bHistorial.setBorderPainted(false);
		bHistorial.addActionListener(this);

		etiquetaNick.setBackground(new java.awt.Color(102, 102, 102));
		etiquetaNick.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaNick.setText(panelPrincipal.nick);
		

		botonSalir.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/menu-salir.png")); // NOI18N
		botonSalir.setBorderPainted(false);
		botonSalir.setBackground(new java.awt.Color(255, 255, 255));
		botonSalir.addActionListener(this);

		panelCentro.setBackground(new java.awt.Color(255, 255, 255));

		bAceptar.setBackground(new java.awt.Color(255, 255, 255));
		bAceptar.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
		bAceptar.setForeground(new java.awt.Color(243, 15, 120));
		bAceptar.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botoneraAceptar.png")); // NOI18N
		bAceptar.setBorder(null);
		bAceptar.addActionListener(this);
		bAceptar.setEnabled(true);
		

		etiquetaNick1.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaNick1.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaNick1.setText("NICK");
		

		etiquetaApellido2
				.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaApellido2.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaApellido2.setText("APELLIDO 1");

		etiquetaEmail.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaEmail.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaEmail.setText("E-MAIL");

		etiquetaPassword
				.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaPassword.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaPassword.setText("PASSWORD");

		etiquetaPassword2
				.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaPassword2.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaPassword2.setText("R. PASSWORD");

		etiquetaNombre.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaNombre.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaNombre.setText("NOMBRE");

		etiquetaProvincia
				.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaProvincia.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaProvincia.setText("PROVINCIA");

		etiquetaApellido1
				.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaApellido1.setForeground(new java.awt.Color(102, 102, 102));
		etiquetaApellido1.setText("APELLIDO2");

		tfNombre.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfNombre.setText(user.getNombre());
		tfNombre.addMouseListener(this);
		

		tfApellido2.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfApellido2.setText(user.getApellido1());
		tfApellido2.addMouseListener(this);
		
		tfApellido1.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfApellido1.setText(user.getApellido2());
		tfApellido1.addMouseListener(this);

		tfNick.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfNick.setText(user.getNick());
		tfNick.addMouseListener(this);
	

		tfEmail.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		tfEmail.setText(user.getEmail());
		tfEmail.addMouseListener(this);

		cbProvincia = new JComboBox<String>(provinciasArray(provincias));
		cbProvincia.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
		cbProvincia.setSelectedIndex(this.cod_provincia);
	

		
		bMapa.setBackground(new java.awt.Color(255, 255, 255));
		bMapa.setFont(new java.awt.Font("Lucida Handwriting", 0, 12)); // NOI18N
		bMapa.setForeground(new java.awt.Color(243, 15, 120));
		bMapa.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonMapa.png")); // NOI18N
		bMapa.setBorder(null);
		bMapa.addActionListener(this);
		
		

		

		
		 org.jdesktop.layout.GroupLayout panelCentroLayout = new org.jdesktop.layout.GroupLayout(panelCentro);
	        panelCentro.setLayout(panelCentroLayout);
	        panelCentroLayout.setHorizontalGroup(
	            panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
	            .add(panelCentroLayout.createSequentialGroup()
	                .addContainerGap()
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
	                    .add(etiquetaNombre)
	                    .add(etiquetaApellido2)
	                    .add(etiquetaApellido1)
	                    .add(etiquetaNick1)
	                    .add(etiquetaEmail)
	                    .add(etiquetaProvincia)
	                    .add(etiquetaPassword)
	                    .add(etiquetaPassword2))
	                .add(59, 59, 59)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
	                    .add(panelCentroLayout.createSequentialGroup()
	                        .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
	                            .add(pfPassword1)
	                            .add(cbProvincia)
	                            .add(pfPassword2))
	                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
	                        .add(bMapa)
	                        .add(16, 16, 16))
	                    .add(panelCentroLayout.createSequentialGroup()
	                        .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
	                            .add(org.jdesktop.layout.GroupLayout.LEADING, tfEmail, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
	                            .add(org.jdesktop.layout.GroupLayout.LEADING, tfNick)
	                            .add(org.jdesktop.layout.GroupLayout.LEADING, tfApellido1)
	                            .add(org.jdesktop.layout.GroupLayout.LEADING, tfApellido2)
	                            .add(org.jdesktop.layout.GroupLayout.LEADING, tfNombre))
	                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
	            .add(org.jdesktop.layout.GroupLayout.TRAILING, panelCentroLayout.createSequentialGroup()
	                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
	                .add(bAceptar)
	                .add(226, 226, 226))
	        );
	        panelCentroLayout.setVerticalGroup(
	            panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
	            .add(panelCentroLayout.createSequentialGroup()
	                .add(53, 53, 53)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(etiquetaNombre)
	                    .add(tfNombre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(etiquetaApellido2)
	                    .add(tfApellido2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
	                    .add(etiquetaApellido1)
	                    .add(tfApellido1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(tfNick, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
	                    .add(etiquetaNick1))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(etiquetaEmail)
	                    .add(tfEmail, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
	                    .add(bMapa)
	                    .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                        .add(etiquetaProvincia)
	                        .add(cbProvincia, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(etiquetaPassword)
	                    .add(pfPassword1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .add(18, 18, 18)
	                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
	                    .add(etiquetaPassword2)
	                    .add(pfPassword2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
	                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
	                .add(bAceptar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
	                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
	        );

		bOpciones.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bOpciones.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonOpciones.png")); // NOI18N
		bOpciones.setBorderPainted(false);
		bOpciones.addActionListener(this);
		bOpciones.setBackground(new java.awt.Color(255, 255, 255));

		etiquetaEntrada.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaEntrada.setForeground(new java.awt.Color(243, 15, 120));
		etiquetaEntrada.setText("BIENVENIDO A LISTA DE LA COMPRA MAKER ");

		bBusqueda.setBackground(new java.awt.Color(255, 255, 255));
		bBusqueda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bBusqueda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonBusqueda.png")); // NOI18N
		bBusqueda.setToolTipText("");
		bBusqueda.setBorderPainted(false);
		bBusqueda.addActionListener(this);

		bAyuda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bAyuda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonAyuda.png")); // NOI18N
		bAyuda.setBorderPainted(false);
		bAyuda.addActionListener(this);
		bAyuda.setBackground(new java.awt.Color(255, 255, 255));

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.addContainerGap()
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(bCrearLista,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												157,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(bBusqueda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												155,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(bHistorial,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												157,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(bSugerencias,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												157,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(bOpciones,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												157,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
								.add(org.jdesktop.layout.GroupLayout.TRAILING,
										bAyuda,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										157,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.add(26, 26, 26)
						.add(panelCentro,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).add(17, 17, 17))
				.add(layout
						.createSequentialGroup()
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout.createSequentialGroup()
										.add(96, 96, 96).add(bTitulo)
										.add(44, 44, 44).add(botonSalir))
								.add(layout
										.createSequentialGroup()
										.add(84, 84, 84)
										.add(etiquetaEntrada)
										.add(46, 46, 46)
										.add(etiquetaNick,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												280,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
						.addContainerGap(
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(bTitulo,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										104,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(botonSalir))
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(etiquetaEntrada).add(etiquetaNick))
						.add(18, 18, 18)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.add(bBusqueda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bCrearLista,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bHistorial,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bSugerencias,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bOpciones,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bAyuda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(0, 67, Short.MAX_VALUE))
								.add(panelCentro,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										0, Short.MAX_VALUE)).addContainerGap()));
	}
	
	public String[] provinciasArray(List<Provincia> provincias) {
		String[] arrayProvincias = new String[provincias.size()];
		for (int i = 0; i < provincias.size(); i++) {
			arrayProvincias[i] = provincias.get(i).getNombre();
		}
		return arrayProvincias;
	}

	private javax.swing.JButton bAceptar;
    private javax.swing.JButton bAyuda;
    private javax.swing.JButton bBusqueda;
    private javax.swing.JButton bCrearLista;
    private javax.swing.JButton bHistorial;
    private javax.swing.JButton bMapa;
    private javax.swing.JButton bOpciones;
    private javax.swing.JButton bSugerencias;
    private javax.swing.JButton bTitulo;
    private javax.swing.JButton botonSalir;
    private javax.swing.JLabel etiquetaApellido1;
    private javax.swing.JLabel etiquetaApellido2;
    private javax.swing.JLabel etiquetaEmail;
    private javax.swing.JLabel etiquetaEntrada;
    private javax.swing.JLabel etiquetaNick;
    private javax.swing.JLabel etiquetaNick1;
    private javax.swing.JLabel etiquetaNombre;
    private javax.swing.JLabel etiquetaPassword;
    private javax.swing.JLabel etiquetaPassword2;
    private javax.swing.JLabel etiquetaProvincia;
    private javax.swing.JPanel panelCentro;
    private javax.swing.JPasswordField pfPassword1;
    private javax.swing.JPasswordField pfPassword2;
    private javax.swing.JTextField tfApellido1;
    private javax.swing.JTextField tfApellido2;
    private javax.swing.JTextField tfEmail;
    private javax.swing.JTextField tfNick;
    private javax.swing.JTextField tfNombre;
    private javax.swing.JComboBox cbProvincia;
	private JFrame actual;
	private JPanel estePanel = this;

	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == bSugerencias) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelSugerencias());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}

		if (e.getSource() == bBusqueda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelBusqueda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}

		if (e.getSource() == bHistorial) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelHistorial());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bAyuda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelAyuda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bCrearLista) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelCrearLista());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bTitulo) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelPrincipal());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == botonSalir) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelSalir(17));
			actual.setPreferredSize(new Dimension(610, 330));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bAceptar) {
			Icon icono = new ImageIcon("src/GUI/resources/error.gif");
			if((tfNombre.getText().length()==0)||(tfNick.getText().length()==0)||(tfEmail.getText().length()==0)
					||(tfApellido1.getText().length()==0)||(tfApellido2.getText().length()==0)||(pfPassword1.getText().length()==0)
					||(pfPassword2.getText().length()==0)){
				
				JOptionPane.showOptionDialog(null, "No se han introducido todos los datos",
						"Cambio Perfil", OK_CANCEL_OPTION, PLAIN_MESSAGE, icono,
						new Object[] { "ACEPTAR" }, null);
				
				
			}else{
					if(!(pfPassword1.getText().equals(pfPassword2.getText()))){
					
					JOptionPane.showOptionDialog(null, "Las passwords introducidas no coinciden",
							"Registro incorrecto", OK_CANCEL_OPTION, PLAIN_MESSAGE, icono,
							new Object[] { "ACEPTAR" }, null);
					
				}else{
					{
						VentanaManager ventanaManager=VentanaFactory.getInstance();
						ventanaManager.ModifyUsuario(new Usuario(tfNick.getText(),tfNombre.getText(),tfApellido1.getText(),tfApellido2.getText(),tfEmail.getText(),cbProvincia.getSelectedIndex(),pfPassword1.getText()));
						Icon iconoAceptar = new ImageIcon("src/GUI/resources/aceptar.gif");
						JOptionPane.showOptionDialog(null, "Registro realizado con exito",
								"Registro nuevo", OK_CANCEL_OPTION, PLAIN_MESSAGE, iconoAceptar,
								new Object[] { "ACEPTAR" }, null);

						actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
						actual.getContentPane().remove(0);
						actual.getContentPane().add(new panelInicio());
						actual.setPreferredSize(new Dimension(610, 350));
						actual.pack();
						actual.repaint();
						UtilidadesGUI.CentrarPantalla(actual);
					}
				}
			}
				
				
				
				
			
		}
		if (e.getSource() == bMapa) {

			Usuario u=new Usuario();
			
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new mapa(u,2));
			actual.setPreferredSize(new Dimension(820, 710));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);
			
			
		}	

	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if((e.getSource()==tfNick)||(e.getSource()==tfNombre)||(e.getSource()==tfApellido1)||(e.getSource()==tfApellido2)
		||(e.getSource()==tfEmail)||(e.getSource()==pfPassword1)||(e.getSource()==pfPassword2)
		){
			bAceptar.setEnabled(true);
		}
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}